import java.sql.SQLOutput;
import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * 测试
 * User: xwl
 * Date: 2023-06-01
 * Time: 20:50
 */

// 学生类--用来做key
class Student {
    private String id;
    // 构造方法
    public Student() {};
    public Student(String id) {
        this.id = id;
    }
    @Override
    public String toString() {
        return "Student{" + '\n'
                + "id=" + id + '\''
                + '\n' +'}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(id, student.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}



// Main
public class Main {
    public static void main(String[] args) {
        HashBuck hashBuck = new HashBuck();
        System.out.println(hashBuck.array.length);
        hashBuck.put(1,11);
        hashBuck.put(2,22);
        hashBuck.put(5,33);
        hashBuck.put(8,44);
        hashBuck.put(7,54);
        hashBuck.put(3,13);
        //  测试扩容
        hashBuck.put(9,21);
        System.out.println(hashBuck.array.length);
        int val = hashBuck.get(5);
        int val2 = hashBuck.get(52);
        System.out.println(val);
        System.out.println(val2);
        // 通过hasCode转化成int类型
        Student student = new Student("123");
        System.out.println(student.hashCode());
        // 测试
        Student student2 = new Student("123");
        Student student3 = new Student("1233");
        System.out.println(student2.hashCode());
        //
        System.out.println(".........");
        HashBuck2<Student,String> hashBuck2 = new HashBuck2<>();
        hashBuck2.put(student,"123");
        hashBuck2.put(student3,"1233");
        String val3 = hashBuck2.get(student);
        System.out.println(val3);
    }
}
